package com.firefoxking.mysite.utils;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data

public class APIResponse <T>{

    private static final String CODE_SUCCESS = "success";

    private static final String CODE_FAIL = "fail";

    private String code;
    private String msg;
    private T data;

    public APIResponse() {

    }

    public APIResponse(String code){
        this.code = code;
    }

    public APIResponse(String code, T data){
        this.code = code;
        this.data = data;
    }

    public APIResponse(String code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public static APIResponse success(){
        return new APIResponse(CODE_SUCCESS);
    }

    public static APIResponse fail(String msg) {
        return new APIResponse(CODE_FAIL, msg);
    }
}
